package com.stormrage.edu.dao.adm.impl;

import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import com.stormrage.edu.dao.adm.AdmAcctResDao;
import com.stormrage.entity.adm.AdmAcctRes;
import com.stormragetech.core.dao.MysBaseDao;
import com.stormragetech.core.exception.StormrageTechException;

/**
 * @author www.stormragetech.com
 * @date 2016年3月7日
 * @version 1.0.0
 */
@Repository
public class AdmAcctResDaoImpl extends MysBaseDao implements AdmAcctResDao {

	private static final Logger logger = LoggerFactory.getLogger(AdmAcctResDaoImpl.class);

	@Override
	public Integer create(final AdmAcctRes arg0) throws StormrageTechException {

		logger.debug(" 【 Dao 】- 【 AdmAcctDao 】- 【 deleteByAcctId 】-【 STARTED 】");

		final String query = "INSERT INTO adm_acct_res (acct_id, res_id) VALUES (:acctId, :resId)";
		logger.debug(" 数据库执行语句为： " + query);

		Integer index = create(query, arg0);

		logger.debug(" 【 Dao 】- 【 AdmAcctDao 】- 【 deleteByAcctId 】-【 COMPLETED 】");
		return index;

	}

	@Override
	public void deleteByAcctId(final Map<String, Object> map) throws StormrageTechException {

		logger.debug(" 【 Dao 】- 【 AdmAcctDao 】- 【 deleteByAcctId 】-【 STARTED 】");

		final String query = "DELETE FROM adm_acct_res WHERE acct_id = :acctId";
		logger.debug(" 数据库执行语句为： " + query);

		update(query, map);

		logger.debug(" 【 Dao 】- 【 AdmAcctDao 】- 【 deleteByAcctId 】-【 COMPLETED 】");

	}

}
